package com.bifang.controller;

import com.alibaba.fastjson.JSON;
import com.bifang.entity.Rst;
import com.bifang.service.CalService;
import com.bifang.utils.MathUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@Controller
public class MainController {
    @Autowired
    private CalService calService;

    @PostMapping(value = "cal")
    @ResponseBody
    public String index(String s){
        String rst = calService.cal(s);
        return JSON.toJSONString(rst);
    }

    @GetMapping("/history")
    public String history(){
        return "history";
    }

    @GetMapping("/getHistory")
    @ResponseBody
    public String getHistory(){
        return JSON.toJSONString(calService.getHistory());
    }
}
